package day15;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Xiao
 * @date 2021/8/8
 */
public class InetAddressDemo01 {
    /**
     * 	static InetAddress getByName(String host)：确定主机名称的IP地址。主机名称可以是机器名称，也可以是IP地址
     * 	String getHostName()：获取此IP地址的主机名
     * 	String getHostAddress()：返回文本显示中的IP地址字符串
     */
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("Qz");
        String hostName = address.getHostName();
        String hostAddress = address.getHostAddress();
        System.out.println(address);
        System.out.println(hostName);
        System.out.println(hostAddress);
    }
}
